//
//  DRLearnCookCell.m
//  DoctorRen
//
//  Created by Lemon on 2018/11/21.
//

#import "DRLearnCookCell.h"
#import "DRLearnCookingModel.h"
#import <YYText/YYText.h>

@interface DRLearnCookCell()
@property (weak, nonatomic) IBOutlet UIImageView *coverIV;

@property (weak, nonatomic) IBOutlet UILabel *userLB;

@property (weak, nonatomic) IBOutlet UILabel *titleLabel;

@property (weak, nonatomic) IBOutlet UILabel *likeLabel;
@property (weak, nonatomic) IBOutlet UIImageView *avatarIV;
@property (weak, nonatomic) IBOutlet UIImageView *playIV;
@property (weak, nonatomic) IBOutlet UIImageView *likeImageView;

@end

@implementation DRLearnCookCell

-(void)awakeFromNib{
    [super awakeFromNib];
    self.avatarIV.layer.cornerRadius = 9;
    self.avatarIV.layer.masksToBounds = YES;
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(likeAction)];
    UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(likeAction)];
    [self.likeLabel addGestureRecognizer:tap];
    [self.likeImageView addGestureRecognizer:tap1];
}

-(void)setData:(DRLearnCookingModel *)data{
    [self.coverIV setImageWithURLString:data.pic_id];
    [self.avatarIV setImageWithURLString:data.user_pic_id];
    self.userLB.text = data.user_id;
    self.titleLabel.text = data.title;
    self.likeLabel.text = data.like_count;
    [self.playIV setHidden:data.img];
    self.likeImageView.image = [UIImage imageNamed:data.is_like ? @"健康煮艺_已赞" :@"健康煮艺_赞"];
}

-(void) likeAction{
    if (self.likeComment) {
        self.likeComment();
    }
}

@end
